
goog.provide('esn.model.StudentModel');


/**
 * @constructor
 */
esn.model.StudentModel = function(modelJson) {
  this.model_ = modelJson;
};

esn.model.StudentModel.prototype.getId = function() {
  return this.model_['id'];
};

esn.model.StudentModel.prototype.getEmailAddress = function() {
  return this.model_['email_address'];
};

esn.model.StudentModel.prototype.getFirstName = function() {
  return this.model_['first_name'];
};

esn.model.StudentModel.prototype.getMiddleName = function() {
  return goog.isDef(this.model_['middle_name']) ? this.model_['middle_name'] :
      '';
};

esn.model.StudentModel.prototype.getLastName = function() {
  return this.model_['last_name'];
};

esn.model.StudentModel.prototype.getFullName = function() {
  if (this.getMiddleName() != '') {
    return this.getFirstName() + ' ' + this.getLastName();
  }
  return this.getFirstName() + ' ' + this.getLastName();
};

esn.model.StudentModel.prototype.isAdmin = function() {
  return !!this.model_['admin'];
};

esn.model.StudentModel.prototype.getFacebookId = function() {
  return this.model_['fb_id'];
};

esn.model.StudentModel.prototype.setFacebookId = function(facebookId) {
  this.model_['fb_id'] = facebookId;
};

esn.model.StudentModel.prototype.hasConsented = function() {
  return !!this.model_['current_session_data']['consented'] ||
      this.getPreviousSessionStatus();
};

esn.model.StudentModel.prototype.setConsented = function(consented) {
  this.model_['current_session_data']['consented'] = consented;
};

esn.model.StudentModel.prototype.getStatus = function() {
  return this.model_['current_session_data']['status'];
};

esn.model.StudentModel.prototype.setStatus = function(status) {
  this.model_['current_session_data']['status'] = status;
};

esn.model.StudentModel.prototype.getPreviousSessionStatus = function() {
  return this.model_['current_session_data']['previous_session_status'];
};

esn.model.StudentModel.prototype.setPreviousSessionStatus = function(status) {
  this.model_['current_session_data']['previous_session_status'] = status;
};

esn.model.StudentModel.prototype.startedPreviousSession = function() {
  return (!!this.model_['current_session_data']['previous_session_status'] &&
          this.model_['current_session_data']['previous_session_status'] !=
              'personal');
};

esn.model.StudentModel.prototype.toString = function() {
  return this.model_['first_name'] + ' ' + this.model_['last_name'];
};

esn.model.StudentModel.prototype.toObject = function() {
  return this.model_;
};
